﻿@{
    Layout = "_Layout.cshtml";
}
@using WebApp.Models
@using WebApp.Extensions
@using Telerik.Web.Mvc.UI
@model IEnumerable<ENT_Tavolo>
@{
    ViewBag.Title = "Lista dei tavoli";
    String sla = (String)ViewData["sla"];
}
@(Html.Telerik().Grid(Model)
        .Name("Grid")
        .ToolBar(commands =>  {
            commands.Insert();
            commands.Custom().Action("SAL_LST", "Setup", new { }).Text("Sala");
        })
        .DataKeys(keys => keys.Add(c => c.Guid))
        .HtmlAttributes(new { @class = "data" })
        .Columns(columns =>
        {
            columns.Bound(o => o.Nome).Sortable(true).Title("Nome");
            columns.Template(o => o.Disponibile.Render()).Title("Disponibile").Width(50);
            columns.Bound(o => o.Posti).Title("Posti").Width(50);
            columns.Bound(o => o.Coperto).Format("{0:C2}").Title("Coperto").Width(80);
            columns.Template(o => o.CopertoUnico.Render()).Title("Unico").Width(120);
            columns.Command(commands =>
            {
                commands.Edit().ButtonType(GridButtonType.Image);
                commands.Delete().ButtonType(GridButtonType.Image);
            }).Width(100);
        })
        .Editable(editing => editing.Mode(GridEditMode.PopUp))
        .DataBinding(dataBinding => dataBinding
            .Server()
               .Select("SAL_TAV_LST", "Setup", new { f0 = sla })
               .Insert("SAL_TAV_INS", "Setup", new { f0 = sla })
               .Update("SAL_TAV_SAV", "Setup", new { f0 = sla })
               .Delete("SAL_TAV_DEL", "Setup", new { f0 = sla }))

)
